function [ normalizedImage ] = normalize( image, outMin, outMax)
% normalize  normalize the original remote sensing image at each band
%
% Read a remote sensing image and max and min value of the normalized image
% normalize the image at each band
% [normailzedImage]=normalize(image, outMin, outMax) 
%
% Input:
% image: the original remote sensing image
% outMin: the min value of the normailzed image
% the default outMin is 0
% outMax: the max value of the normailzed image
% the default outMax is 0
%
% Output:
% normailzedImage: the normalized remote sensing image
%
%%%%%%%%%%%%%%%%%%%

% check the parameter
if ~exist('outMin','var')
    outMin=0;
end
if ~exist('outMax','var')
    outMax=1;
end 
imageSize=size(image);
normalizedImage=zeros(imageSize(1), imageSize(2), imageSize(3));
numPixels=imageSize(1)*imageSize(2);
% Normalize each band into [outMin,outMax]
for i=1:imageSize(3)
    tempBand=reshape(image(:,:,i),1,numPixels);
    normalizedTempBand=mapminmax(tempBand,outMin,outMax);
    normalizedImage(:,:,i)=reshape(normalizedTempBand,imageSize(1),imageSize(2));
end


